package leetcode_2501_2600;

import java.util.HashSet;
import java.util.Set;

public class LeeCode_2521 {
    public static void main(String[] args) {
        System.out.println(distinctPrimeFactors(new int[]{2, 4, 3, 7, 10, 6}));
        System.out.println(charge(4));
    }
    private static int distinctPrimeFactors(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            int i = 1;
            while (i * i <= num){
                if (num % i == 0){
                    if (charge(i))
                        set.add(i);
                    if (charge(num / i))
                        set.add(num / i);
                }
                i++;
            }
        }
        return set.size();
    }
    private static boolean charge(int x){
        if (x == 1)
            return false;
        int i = 2;
        while (i * i <= x){
            if (x % i == 0)
                return false;
            i++;
        }
        return true;
    }
}
